From: Aleksey Kladov Date: Mon, 2 Apr 2018 20:51:48 +0000 (+0300) Subject: Make TargetInfo.cfg private X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~106^2~3 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=a80071fe3f2a8d3692bcfdf08698ae2dc3772a72;p=cargo.git Make TargetInfo.cfg private --- diff --git a/src/cargo/ops/cargo_rustc/context/mod.rs b/src/cargo/ops/cargo_rustc/context/mod.rs index f54b8015f..36857b1a7 100644 --- a/src/cargo/ops/cargo_rustc/context/mod.rs +++ b/src/cargo/ops/cargo_rustc/context/mod.rs @@ -315,7 +315,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Kind::Host => (self.host_triple(), &self.host_info), Kind::Target => (self.target_triple(), &self.target_info), }; - platform.matches(name, info.cfg.as_ref().map(|cfg| &cfg[..])) + platform.matches(name, info.cfg()) } /// Gets a package for the given package id. @@ -339,7 +339,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Kind::Host => &self.host_info, Kind::Target => &self.target_info, }; - info.cfg.as_ref().map(|s| &s[..]).unwrap_or(&[]) + info.cfg().unwrap_or(&[]) } /// Get the target configuration for a particular host or target @@ -425,7 +425,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { env_args( self.config, &self.build_config, - self.info(&unit.kind), + self.info(&unit.kind).cfg(), unit.kind, "RUSTFLAGS", ) @@ -435,7 +435,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { env_args( self.config, &self.build_config, - self.info(&unit.kind), + self.info(&unit.kind).cfg(), unit.kind, "RUSTDOCFLAGS", ) @@ -473,7 +473,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { fn env_args( config: &Config, build_config: &BuildConfig, - target_info: &TargetInfo, + target_cfg: Option<&[Cfg]>, kind: Kind, name: &str, ) -> CargoResult> { @@ -531,7 +531,7 @@ fn env_args( rustflags.extend(args); } // ...including target.'cfg(...)'.rustflags - if let Some(ref target_cfg) = target_info.cfg { + if let Some(target_cfg) = target_cfg { if let Some(table) = config.get_table("target")? { let cfgs = table.val.keys().filter_map(|t| { if t.starts_with("cfg(") && t.ends_with(')') { diff --git a/src/cargo/ops/cargo_rustc/context/target_info.rs b/src/cargo/ops/cargo_rustc/context/target_info.rs index 17f3ac7e6..1514ab28f 100644 --- a/src/cargo/ops/cargo_rustc/context/target_info.rs +++ b/src/cargo/ops/cargo_rustc/context/target_info.rs @@ -12,8 +12,8 @@ use ops::Kind; pub struct TargetInfo { crate_type_process: Option, crate_types: RefCell>>, - pub(super) cfg: Option>, - pub(super) sysroot_libdir: Option, + cfg: Option>, + pub sysroot_libdir: Option, } /// Type of each file generated by a Unit. @@ -36,13 +36,7 @@ pub struct FileType { impl TargetInfo { pub fn new(cx: &Context, kind: Kind) -> CargoResult { - let rustflags = env_args( - cx.config, - &cx.build_config, - cx.info(&kind), - kind, - "RUSTFLAGS", - )?; + let rustflags = env_args(cx.config, &cx.build_config, None, kind, "RUSTFLAGS")?; let mut process = cx.config.rustc()?.process(); process .arg("-") @@ -125,6 +119,10 @@ impl TargetInfo { }) } + pub fn cfg(&self) -> Option<&[Cfg]> { + self.cfg.as_ref().map(|v| v.as_ref()) + } + pub fn file_types( &self, crate_type: &str,